package cn.shengongying.model;

import cn.shengongying.bean.BaseModal;
import cn.shengongying.utils.DateUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 用户优惠券信息
 * </p>
 *
 * @author RXK
 * @since 2022-01-10
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class UserDiscountInfo extends BaseModal {

    private static final long serialVersionUID = 1L;

    /**
     * 雇主id
     */
    private Long userId;

    /**
     * 金额
     */
    private Integer money;

    /**
     * 优惠券类型(0:折扣券)
     */
    private Integer type;

    /**
     * 状态(0:未使用;1:已使用)
     */
    private Integer status;

    /**
     * 有效期
     */
    private Date validateDate;

    private static final int[] discount_amount = {50,30,20};

    public static List<UserDiscountInfo> newUser(Long userId) {
        List<UserDiscountInfo> list = new ArrayList<>(6);

        for (int i = 0; i < 3; i++) {
            UserDiscountInfo first = new UserDiscountInfo();
            first.setUserId(userId);
            first.setMoney(discount_amount[i]);
            first.setType(0);
            first.setStatus(0);
            first.setValidateDate(DateUtils.add(1, ChronoUnit.YEARS));
            list.add(first);
        }

        return list;
    }
}
